﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Drawing;

public partial class Admin_LookBorrowButNotReturn : System.Web.UI.Page
{
    public static string sqlpa = "";

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Cancel_Click(object sender, EventArgs e)
    {

        sqlpa = "select Book_info.BookID as 图书编号,Book_info.BookName as 图书条目,Book_info.Writer as 作者,Book_info.BookPlace as 馆藏地点,Borrow_books_manage.LendBookDate as 借书日期, returndate as 还书时间, Borrow_books_manage.XUJIETIMES as 续借次数,readername as 读者姓名 from Reader_info, Book_info , Borrow_books_manage where Borrow_books_manage.bookid=Book_info.bookid and Reader_info.ReaderID=Borrow_books_manage.ReaderID and (LendBookDate between '" + date1.Value.ToString() + "' and '" + date2.Value.ToString() + "') and ReturnDate is  null ";
        SqlDataSource1.SelectCommand = sqlpa;


        SqlDataSource1.SelectParameters["name"].DefaultValue = "1";
        SqlDataSource1.SelectParameters["date1"].DefaultValue = date1.Value.ToString();
        SqlDataSource1.SelectParameters["date2"].DefaultValue = date2.Value.ToString();

    }
    protected void baobiao_Click(object sender, EventArgs e)
    {

        SQL sql = new SQL();
        DataSet ds = sql.getDataset(sqlpa, "");
        DataTable dt = new DataTable();
        dt = ds.Tables[0];

        try
        {
            int dateflag = DateTime.Now.GetHashCode();
            OutFileDao.OutFileToDisk(dt, "借出未归还记录查询", "F:\\数据库课设\\BookManage\\reports\\借出未归还记录查询" + dateflag + ".xls");
            Response.AddHeader("Content-Disposition", "attachment;filename=" + "../reports/借出未归还记录查询" + dateflag + ".xls" + "");
            Response.TransmitFile("../reports/借出未归还记录查询" + dateflag + ".xls");//下载文件，backupath是你服务器上文件地址
            Response.Write("<script language=javascript>alert('导出成功');window.location = 'LookBorrowButNotReturn.aspx';</script>");
        }
        catch (System.Exception ex)
        {
            Response.Write("<script language=javascript>alert('导出失败');window.location = 'LookBorrowButNotReturn.aspx';</script>");
        }



    }


    protected void reader_Click(object sender, EventArgs e)
    {

        sqlpa = "select Book_info.BookID as 图书编号,Book_info.BookName as 图书条目,Book_info.Writer as 作者,Book_info.BookPlace as 馆藏地点,Borrow_books_manage.LendBookDate as 借书日期, returndate as 还书时间, Borrow_books_manage.XUJIETIMES as 续借次数,readername as 读者姓名 from Reader_info, Book_info , Borrow_books_manage where Borrow_books_manage.bookid=Book_info.bookid and Reader_info.ReaderID=Borrow_books_manage.ReaderID and (LendBookDate between '" + date1.Value.ToString() + "' and '" + date2.Value.ToString() + "')  and ReturnDate is  null and reader_info.readerID='" + TextBox1.Text + "' ";
        SqlDataSource1.SelectCommand = sqlpa;


        SqlDataSource1.SelectParameters["name"].DefaultValue = "1";
        SqlDataSource1.SelectParameters["date1"].DefaultValue = date1.Value.ToString();
        SqlDataSource1.SelectParameters["date2"].DefaultValue = date2.Value.ToString();

    }

    protected void book_Click(object sender, EventArgs e)
    {

        sqlpa = "select Book_info.BookID as 图书编号,Book_info.BookName as 图书条目,Book_info.Writer as 作者,Book_info.BookPlace as 馆藏地点,Borrow_books_manage.LendBookDate as 借书日期, returndate as 还书时间, Borrow_books_manage.XUJIETIMES as 续借次数,readername as 读者姓名 from Reader_info, Book_info , Borrow_books_manage where Borrow_books_manage.bookid=Book_info.bookid and Reader_info.ReaderID=Borrow_books_manage.ReaderID and  (LendBookDate between '" + date1.Value.ToString() + "' and '" + date2.Value.ToString() + "') and ReturnDate is  null and book_info.bookID='" + TextBox1.Text + "' ";
        SqlDataSource1.SelectCommand = sqlpa;


        SqlDataSource1.SelectParameters["name"].DefaultValue = "1";
        SqlDataSource1.SelectParameters["date1"].DefaultValue = date1.Value.ToString();
        SqlDataSource1.SelectParameters["date2"].DefaultValue = date2.Value.ToString();

    }
}